package com.kezhou.kezhoucloud.mapper;

import com.kezhou.kezhoucloud.entity.AccountSt;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface KeZhouMapper {
    @Select("SELECT * FROM account_st WHERE phoneNum = #{phoneNum};")
    List<AccountSt> getAllAccountsByPhone(String phoneNum);

    @Insert("INSERT INTO account_st (phoneNum, passwordDetail, accountPer, nickName) VALUES (#{phoneNum}, #{password}, 0, '未设置')")
    boolean insertNewAccount(String phoneNum, String password);

    @Update("UPDATE account_st SET passwordDetail = #{newPassword} WHERE phoneNum = #{phoneNum}")
    boolean resetPassword(String phoneNum, String newPassword);

    @Select("SELECT accountId FROM account_st WHERE phoneNum = #{phoneNum}")
    int getAccountId(String phoneNum);
}
